<template>
    <van-nav-bar class="myhead" fixed border placeholder :class="bg?'bg':''"  >
        <template #title>
            <span >{{ title }}</span>
        </template>

        <template #left>
            <slot >
                <!-- 有fromPath 就有返回 没有就直接进入 home / index  -->
                <template v-if="fromPath">
                    <div @click="goback" v-if="!noback">
                        <van-icon name="arrow-left" color="#333" />
                        <span style="color:#1989fa" v-if="false">返回</span>
                    </div>
                </template>
                <div @click="gotohome" v-else>
                    <van-icon name="wap-home-o" color="#333" />
                </div>
            </slot>
        </template>

        <template #right>
            
        </template>
    </van-nav-bar>
</template>


<script>
export default {
    data(){
        return {

        }
    },
    methods:{
        goback(){
            if(this.flag){
                this.$router.push('/index')
            }else{
                this.$router.go(-1)
            }
            
        },
        gotohome(){
            this.$router.push("/index")
        }
    },
    props:{
        flag:Boolean,
        title:String,
        noback:Boolean,  
        bg:{
            type:Boolean,
            default(){
                return false
            }
        },
    },
    mounted(){
        console.log(this.$route.path)
        console.log(this.$route.name)
        
    }
}
</script>

<style lang="scss" scoped>
.myhead{
    width:100%;
    background: #fff;
    // color:#fff;
    // background-color: rgba(248, 248, 248, 1);
}
.bg{
    background: #f8f8f8 !important;
}
</style>
